package javaCode;

/**
 * Created by lxy_920912 on 2017/1/18.
 */
public class LeetCode343 {
    public int integerBreak(int n) {
        if(n == 2){
            return 1;
        }
        if(n == 3){
            return 2;
        }
        int [] result= new int[n+1];
        result[2] = 2;
        result[3] = 3;
        result[4] = 4;
        for(int i = 5;i <= n;i++){
            int s1 = result[2]*result[i-2];
            int s2 = result[3]*result[i-3];
            result[i] = s1>s2?s1:s2;
        }

        return result[n];
    }
}
